package com.rzj.book.dao;

import com.rzj.book.en.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.MySqlMapper;

/**
 * @description:
 * @author: rzj
 * @time: 2020/6/3 21:25
 */
public interface ICategoryDao extends Mapper<Category>, MySqlMapper<Category> {

    @Update("<script>" +
            " update Category SET id = #{category.id}" +
            "<if test='category.name != null'>" +
            " ,name = #{category.name} " +
            "</if>" +
            "<if test='category.type != null'>" +
            " ,type = #{category.type} " +
            "</if>" +
            "<if test='category.pid != null'>" +
            " ,pid = #{category.pid} " +
            "</if>" +
            " where id = #{category.id} "+
            "</script>")
    void updateById(@Param("category")Category category);

    @Delete("delete FROM Category where id = #{id}")
    void deleteCategory(Integer id);
}
